﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace shopxachtayphap
{
    public class Untils
    {
        internal static string LoadNsx(string active,string category)
        {
            string list = string.Empty;
            using (var shop = new WebxachtayEntities())
            {
                var nsx = shop.Manufacturers.Where(x => x.Category.Contains(category)).ToList();
                
                foreach (var manufacturer in nsx)
                {
                    string id = manufacturer.ID.ToString();
                    string classAcive = id == active ?"<li class=\"active\">": "<li>" ;
                    list +=
                        string.Format("{0}<a href=\"Products.aspx?category={1}&product={2}\"><div>",classAcive,category ,manufacturer.ID) +
                        manufacturer.Name + "</div></a></li>";
                }
               
            }
            return list;
        }

        internal static string LoadCategory(string active)
        {
            string list = string.Empty;
            using (var shop = new WebxachtayEntities())
            {
                var categorys = shop.Categories.ToList();

                foreach (var item in categorys)
                {
                    var id = item.ID.ToString();
                    string classAcive = id == active ? "<li class=\"level0 active\">" : "<li class=\"level0\">";
                    list +=
                        string.Format("{0}<a href=\"Products.aspx?category={2}\">{1}<span></span></a></li>", classAcive, item.Name, id);

                }

            }
            return list;
        }
    }
}